package edu.sctu.zcy.month201505.day20150529.synchronize;

/**
 * Created by user24 on 2015/5/29.
 */
public class SynchronizeDemo {


    public boolean ready = false;
    public int result = 0;
    public int number1 = 1;

    public synchronized void write(){

        ready = true;
        number1 = 2;
    }

    public  void read(){

        if(ready){
            System.out.println(result = number1*3);

        }else {
            System.out.println( "结果："+result);
        }
    }
}
